<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div class="left-sidebar">
    <!-- 用户信息 -->
    <div class="tpl-sidebar-user-panel">
        <div class="tpl-user-panel-slide-toggleable">

            <form id="avatarForm" method="post" action="/userDetail/uploadAvatar.do" enctype="multipart/form-data">
                <div class="am-form-group am-form-file">
                    <div class="tpl-user-panel-profile-picture">
                        <img id="avatarImg" src="/userDetail/showAvatar.do" alt="">
                    </div>

                    <input id="doc-form-file" type="file" name="avatarFile" multiple="" onchange="uploadAvatar();">
                </div>

                <input name="username">
                <input type="submit" value="上传头像">

            </form>


            <a href="javascript:;" class="tpl-user-panel-action-link"> <span class="am-icon-pencil"></span> 账号设置</a>
        </div>
    </div>

    <!-- 菜单 -->
    <ul class="sidebar-nav">

        <li class="sidebar-nav-link">
            <a id="indexA" href="/user/toIndex.do" >
                <i class="am-icon-home sidebar-nav-link-logo"></i> 首页
            </a>
        </li>
        <li class="sidebar-nav-link">
            <a id="openaccountA" href="/card/toOpenaccount.do">
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 开户
            </a>
        </li>
        <li class="sidebar-nav-link">
            <a id="drawA" href="/card/toDraw.do" >
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 取款
            </a>
        </li>
        <li class="sidebar-nav-link">
            <a id="depositA" href="/card/toDeposit.do">
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 存款

            </a>
        </li>
        <li class="sidebar-nav-link">
            <a id="transferA" href="/card/toTransfer.do">
                <i class="am-icon-wpforms sidebar-nav-link-logo"></i> 转账
            </a>
        </li>

        <li class="sidebar-nav-link">
            <a id="flowA" href="/flow/toFlow.do">
                <i class="am-icon-bar-chart sidebar-nav-link-logo"></i> 流水

            </a>
        </li>

        <li class="sidebar-nav-link">
            <a id="emailA" href="/email/toEmail.do">
                <i class="am-icon-bar-chart sidebar-nav-link-logo"></i> 绑定邮箱
            </a>
        </li>



    </ul>
</div>

<script src="/js/jquery.form.js"></script>
<script>

    function uploadAvatar() {
        alert(666);
        //上传头像

        $('#avatarForm').ajaxSubmit({
            // 规定把请求发送到那个URL
            url: "/userDetail/uploadAvatar.do",

            // 请求方式
            type: "post",

            // 服务器响应的数据类型
            dataType: "json",

            // 请求成功时执行的回调函数
            success: function(data, status, xhr) {
               alert('上传成功');
                $('#avatarImg').attr('src', '/userDetail/showAvatar.do?k=' + new Date().getTime());
            }
        });

    }
</script>